import request from "@/util/request";
import type {PageType} from "@/api/type";

enum API {
    FILE_PAGE = "/file/page",
    FILE_UPLOAD= "/file/upload",
    FILE= "/file",
    FILE_BUCKET_List = "/file/bucket/list",
    FILE_BUCKET = "/file/bucket",
    FILE_SCENE_LIST= "/file/scene/list",
    FILE_SCENE= "/file/scene",
    CHUNK_MERGE= "/file/upload/chunk/merge",
}
export function reqCheckFile(md5:string){
    return request({
        url:"/file/check",
        method: "get",
        params: {
            md5
        }
    });
}
export function reqCheckChunkFile(sceneCode,md5,index){
    return request({
        url:"/file/chunk/check",
        method: "get",
        params: {
            sceneCode,
            md5,
            index
        }
    });
}

export function reqGetFilePage(query: any){
    return request<PageType<Object>>({
        url: API.FILE_PAGE,
        method: "get",
        params: query
    });
}
export function reqFileChunkMerge(data: any){
    return request({
        url: API.CHUNK_MERGE,
        method: "post",
        data
    });
}
export function reqGetFile(id: string){
    return request({
        url: API.FILE + "/" + id,
        method: "get",
    });
}
export function reqDeleteFile(id: string){
    return request({
        url: API.FILE + "/" + id,
        method: "delete",
    });
}
export function reqUploadFile(data: FormData){
    return request({
        url: API.FILE_UPLOAD+"/common",
        method: "post",
        data
    });
}
export function reqGetBucketList(){
    return request({
        url: API.FILE_BUCKET_List,
        method: "get",
    });
}
export function reqUpdateBucket(data: any){
    return request({
        url: API.FILE_BUCKET,
        method: "put",
        data
    });
}

export function reqGetSceneList(){
    return request({
        url: API.FILE_SCENE_LIST,
        method: "get",
    });
}
export function reqUpdateScene(data: any){
    return request({
        url: API.FILE_SCENE,
        method: "put",
        data
    });
}
